package cn.wildfirechat.app.webhook.github.pojo;

import com.google.gson.Gson;

//https://developer.github.com/v3/activity/events/types/#issuesevent
public class IssueEvent {
    //The action that was performed. Can be one of opened, edited, deleted, pinned, unpinned, closed, reopened, assigned, unassigned, labeled, unlabeled, locked, unlocked, transferred, milestoned, or demilestoned.
    public String action;
    public Issue issue;
    public Repository repository;
    public Sender sender;

    public static IssueEvent fromJson(String jsonStr) {
        return new Gson().fromJson(jsonStr, IssueEvent.class);
    }

    public static void main(String[] args) {
        String event1 = "{\"action\":\"closed\",\"issue\":{\"url\":\"https://api.github.com/repos/wildfirechat/server/issues/257\",\"repository_url\":\"https://api.github.com/repos/wildfirechat/server\",\"labels_url\":\"https://api.github.com/repos/wildfirechat/server/issues/257/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/wildfirechat/server/issues/257/comments\",\"events_url\":\"https://api.github.com/repos/wildfirechat/server/issues/257/events\",\"html_url\":\"https://github.com/wildfirechat/server/issues/257\",\"id\":681562734,\"node_id\":\"MDU6SXNzdWU2ODE1NjI3MzQ=\",\"number\":257,\"title\":\"建议：用户在线状态回调希望回调所在包名称或当前登录的包唯一标识\",\"user\":{\"login\":\"zuoliang0\",\"id\":8434253,\"node_id\":\"MDQ6VXNlcjg0MzQyNTM=\",\"avatar_url\":\"https://avatars1.githubusercontent.com/u/8434253?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/zuoliang0\",\"html_url\":\"https://github.com/zuoliang0\",\"followers_url\":\"https://api.github.com/users/zuoliang0/followers\",\"following_url\":\"https://api.github.com/users/zuoliang0/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/zuoliang0/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/zuoliang0/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/zuoliang0/subscriptions\",\"organizations_url\":\"https://api.github.com/users/zuoliang0/orgs\",\"repos_url\":\"https://api.github.com/users/zuoliang0/repos\",\"events_url\":\"https://api.github.com/users/zuoliang0/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/zuoliang0/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[{\"id\":1205138170,\"node_id\":\"MDU6TGFiZWwxMjA1MTM4MTcw\",\"url\":\"https://api.github.com/repos/wildfirechat/server/labels/enhancement\",\"name\":\"enhancement\",\"color\":\"a2eeef\",\"default\":true,\"description\":\"New feature or request\"}],\"state\":\"closed\",\"locked\":false,\"assignee\":null,\"assignees\":[],\"milestone\":null,\"comments\":14,\"created_at\":\"2020-08-19T05:41:55Z\",\"updated_at\":\"2020-08-27T05:26:57Z\",\"closed_at\":\"2020-08-27T05:26:57Z\",\"author_association\":\"NONE\",\"active_lock_reason\":null,\"body\":\"回调在线状态这个需求也是我提出的，我们现在使用的是融云服务，计划在年底迁移到野火，目前正在做前期对接，后台对接时发现回调状态不包含当前所登录的包信息，希望能拿到这些信息。我们有多个app，用户可以在多个app之间登录。\",\"performed_via_github_app\":null},\"repository\":{\"id\":167204613,\"node_id\":\"MDEwOlJlcG9zaXRvcnkxNjcyMDQ2MTM=\",\"name\":\"server\",\"full_name\":\"wildfirechat/server\",\"private\":false,\"owner\":{\"login\":\"wildfirechat\",\"id\":33191460,\"node_id\":\"MDEyOk9yZ2FuaXphdGlvbjMzMTkxNDYw\",\"avatar_url\":\"https://avatars0.githubusercontent.com/u/33191460?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/wildfirechat\",\"html_url\":\"https://github.com/wildfirechat\",\"followers_url\":\"https://api.github.com/users/wildfirechat/followers\",\"following_url\":\"https://api.github.com/users/wildfirechat/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/wildfirechat/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/wildfirechat/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/wildfirechat/subscriptions\",\"organizations_url\":\"https://api.github.com/users/wildfirechat/orgs\",\"repos_url\":\"https://api.github.com/users/wildfirechat/repos\",\"events_url\":\"https://api.github.com/users/wildfirechat/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/wildfirechat/received_events\",\"type\":\"Organization\",\"site_admin\":false},\"html_url\":\"https://github.com/wildfirechat/server\",\"description\":\"即时通讯(IM)系统\",\"fork\":false,\"url\":\"https://api.github.com/repos/wildfirechat/server\",\"forks_url\":\"https://api.github.com/repos/wildfirechat/server/forks\",\"keys_url\":\"https://api.github.com/repos/wildfirechat/server/keys{/key_id}\",\"collaborators_url\":\"https://api.github.com/repos/wildfirechat/server/collaborators{/collaborator}\",\"teams_url\":\"https://api.github.com/repos/wildfirechat/server/teams\",\"hooks_url\":\"https://api.github.com/repos/wildfirechat/server/hooks\",\"issue_events_url\":\"https://api.github.com/repos/wildfirechat/server/issues/events{/number}\",\"events_url\":\"https://api.github.com/repos/wildfirechat/server/events\",\"assignees_url\":\"https://api.github.com/repos/wildfirechat/server/assignees{/user}\",\"branches_url\":\"https://api.github.com/repos/wildfirechat/server/branches{/branch}\",\"tags_url\":\"https://api.github.com/repos/wildfirechat/server/tags\",\"blobs_url\":\"https://api.github.com/repos/wildfirechat/server/git/blobs{/sha}\",\"git_tags_url\":\"https://api.github.com/repos/wildfirechat/server/git/tags{/sha}\",\"git_refs_url\":\"https://api.github.com/repos/wildfirechat/server/git/refs{/sha}\",\"trees_url\":\"https://api.github.com/repos/wildfirechat/server/git/trees{/sha}\",\"statuses_url\":\"https://api.github.com/repos/wildfirechat/server/statuses/{sha}\",\"languages_url\":\"https://api.github.com/repos/wildfirechat/server/languages\",\"stargazers_url\":\"https://api.github.com/repos/wildfirechat/server/stargazers\",\"contributors_url\":\"https://api.github.com/repos/wildfirechat/server/contributors\",\"subscribers_url\":\"https://api.github.com/repos/wildfirechat/server/subscribers\",\"subscription_url\":\"https://api.github.com/repos/wildfirechat/server/subscription\",\"commits_url\":\"https://api.github.com/repos/wildfirechat/server/commits{/sha}\",\"git_commits_url\":\"https://api.github.com/repos/wildfirechat/server/git/commits{/sha}\",\"comments_url\":\"https://api.github.com/repos/wildfirechat/server/comments{/number}\",\"issue_comment_url\":\"https://api.github.com/repos/wildfirechat/server/issues/comments{/number}\",\"contents_url\":\"https://api.github.com/repos/wildfirechat/server/contents/{+path}\",\"compare_url\":\"https://api.github.com/repos/wildfirechat/server/compare/{base}...{head}\",\"merges_url\":\"https://api.github.com/repos/wildfirechat/server/merges\",\"archive_url\":\"https://api.github.com/repos/wildfirechat/server/{archive_format}{/ref}\",\"downloads_url\":\"https://api.github.com/repos/wildfirechat/server/downloads\",\"issues_url\":\"https://api.github.com/repos/wildfirechat/server/issues{/number}\",\"pulls_url\":\"https://api.github.com/repos/wildfirechat/server/pulls{/number}\",\"milestones_url\":\"https://api.github.com/repos/wildfirechat/server/milestones{/number}\",\"notifications_url\":\"https://api.github.com/repos/wildfirechat/server/notifications{?since,all,participating}\",\"labels_url\":\"https://api.github.com/repos/wildfirechat/server/labels{/name}\",\"releases_url\":\"https://api.github.com/repos/wildfirechat/server/releases{/id}\",\"deployments_url\":\"https://api.github.com/repos/wildfirechat/server/deployments\",\"created_at\":\"2019-01-23T15:21:28Z\",\"updated_at\":\"2020-08-26T12:17:45Z\",\"pushed_at\":\"2020-08-25T13:04:59Z\",\"git_url\":\"git://github.com/wildfirechat/server.git\",\"ssh_url\":\"git@github.com:wildfirechat/server.git\",\"clone_url\":\"https://github.com/wildfirechat/server.git\",\"svn_url\":\"https://github.com/wildfirechat/server\",\"homepage\":\"http://docs.wildfirechat.cn\",\"size\":9350,\"stargazers_count\":5330,\"watchers_count\":5330,\"language\":\"Java\",\"has_issues\":true,\"has_projects\":true,\"has_downloads\":true,\"has_wiki\":true,\"has_pages\":false,\"forks_count\":1204,\"mirror_url\":null,\"archived\":false,\"disabled\":false,\"open_issues_count\":9,\"license\":{\"key\":\"other\",\"name\":\"Other\",\"spdx_id\":\"NOASSERTION\",\"url\":null,\"node_id\":\"MDc6TGljZW5zZTA=\"},\"forks\":1204,\"open_issues\":9,\"watchers\":5330,\"default_branch\":\"wildfirechat\"},\"organization\":{\"login\":\"wildfirechat\",\"id\":33191460,\"node_id\":\"MDEyOk9yZ2FuaXphdGlvbjMzMTkxNDYw\",\"url\":\"https://api.github.com/orgs/wildfirechat\",\"repos_url\":\"https://api.github.com/orgs/wildfirechat/repos\",\"events_url\":\"https://api.github.com/orgs/wildfirechat/events\",\"hooks_url\":\"https://api.github.com/orgs/wildfirechat/hooks\",\"issues_url\":\"https://api.github.com/orgs/wildfirechat/issues\",\"members_url\":\"https://api.github.com/orgs/wildfirechat/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/wildfirechat/public_members{/member}\",\"avatar_url\":\"https://avatars0.githubusercontent.com/u/33191460?v=4\",\"description\":\"北京野火无限网络科技有限公司--专注于即时通讯技术，提供优质可控的即时通讯能力\"},\"sender\":{\"login\":\"heavyrain2012\",\"id\":34463389,\"node_id\":\"MDQ6VXNlcjM0NDYzMzg5\",\"avatar_url\":\"https://avatars0.githubusercontent.com/u/34463389?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/heavyrain2012\",\"html_url\":\"https://github.com/heavyrain2012\",\"followers_url\":\"https://api.github.com/users/heavyrain2012/followers\",\"following_url\":\"https://api.github.com/users/heavyrain2012/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/heavyrain2012/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/heavyrain2012/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/heavyrain2012/subscriptions\",\"organizations_url\":\"https://api.github.com/users/heavyrain2012/orgs\",\"repos_url\":\"https://api.github.com/users/heavyrain2012/repos\",\"events_url\":\"https://api.github.com/users/heavyrain2012/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/heavyrain2012/received_events\",\"type\":\"User\",\"site_admin\":false}}";
        IssueEvent openedIssue = new Gson().fromJson(event1, IssueEvent.class);
        System.out.println(openedIssue.action);
    }
}
